﻿/*
 * Cratos Desktop
 * Cratos Proxy Chaching interface declaration
 * 
 * Copyright (c) 2011 Draco
 * 
 * This file is part of Cratos.
 * 
 * Cratos is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Cratos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cratos.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *       .==.        .==.
 *      //'^\\      //^'\\
 *     // ^ ^\(\__/)/^ ^^\\
 *    //^ ^^ ^/6  6\ ^^ ^ \\
 *   //^ ^^ ^/( .. )\^ ^ ^ \\
 *  // ^^ ^/\| V""V|/\^ ^ ^ \\
 * //^^/\/ /  '~~'  \ \/\^ ^ \\
 *  ------------------------------------
 *  HERE BE DRAGONS
 *  
 *  Johan Dercksen - johan@draco.co.za
 */
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Cratos.Tools.General;

namespace Cratos.Desktop
{
	/// <summary>
	/// Cratos Caching Interface declaration
	/// </summary>
	public interface ICratosCaching
	{
		#region Event declarations
		/// <summary>
		/// Cache Refresh Started
		/// </summary>
		event EventHandler CacheRefreshStarted;

		/// <summary>
		/// Cache Refresh Completed
		/// </summary>
		event EventHandler CacheRefreshCompleted;
		#endregion

		#region Property declarations
		/// <summary>
		/// Caching Enbled indicator
		/// </summary>
		bool CachingEnabled { get; set; }

		/// <summary>
		/// Cache Filename
		/// </summary>
		string CacheFilename { get; set; }

		/// <summary>
		/// Cache Expiry Seed value (Minutes)
		/// </summary>
		long CacheExpirySeed { get; set; }

		/// <summary>
		/// Cache Refresh Interval (Seconds)
		/// </summary>
		int CacheRefreshInterval { get; set; }
		#endregion

		#region Method declarations
		/// <summary>
		/// Load Cache
		/// </summary>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		bool LoadCache();

		/// <summary>
		/// Refresh the Cache
		/// </summary>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		void RefreshCache();

		/// <summary>
		/// Clear Cache
		/// </summary>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		bool ClearCache();

		/// <summary>
		/// Save Cache
		/// </summary>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		bool SaveCache();

		/// <summary>
		/// Add new Cache Item
		/// </summary>
		/// <param name="newItem">New cache Item</param>
		/// <param name="cacheAssemblyElement">Cache Assembly Element</param>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		bool AddCacheItem(IDOCratos newItem, CacheAssemblyElement cacheAssemblyElement);

		/// <summary>
		/// Add new Cache Item
		/// </summary>
		/// <param name="newItem">New cache Item</param>
		/// <param name="cacheAssemblyElement">Cache Assembly Element</param>
		/// <returns>A boolean value is returned indicating the success of the method</returns>
		bool AddCacheItem(string newItem, CacheAssemblyElement cacheAssemblyElement);

		/// <summary>
		/// Retrieve the objects of the specified Data Type
		/// </summary>
		/// <param name="doDataType">Data Type</param>
		/// <returns>A list of objects containing the objects</returns>
		List<IDOCratos> RetrieveItems(string doDataType);

		/// <summary>
		/// Get the Last Date and Time a DO was updated
		/// </summary>
		/// <param name="doDataType">Data Type</param>
		/// <returns>Last Date updated or null</returns>
		Nullable<DateTime> GetLastDateDOUpdated(string doDataType);
		#endregion
	}
}
